#!/bin/bash

# Function to check if gnome-control-center is running
is_gcc_running() {
    # ps aux | grep -v grep | grep -q '/usr/bin/gnome-control-center'
    ps aux | grep -v grep | grep -q 'gnome-control-center'
    return $?
}

# Function to restart gnome-control-center
restart_gcc() {
    # echo 1|sudo -S shutdown now
    reboot
}


is_software(){
    ps aux | grep -v grep | grep -q 'software-proper'
    return $?
}

is_update(){
    ps aux | grep -v grep | grep -q 'update-manager'
    return $?
}


# Infinite loop to monitor the process
if is_gcc_running; then
    echo "gnome-control-center is running. Restarting..."
    restart_gcc
else
    echo "gnome-control-center is not running."
fi
# Sleep for a specified time before checking again (e.g., 10 seconds)


if is_software; then
    echo "software-properties-gtk is running."
    pkill software-proper
else
    echo "software-properties-gtk is not running."
fi


if is_update; then
    echo "update-manager is running."
    pkill update-manager
else
    echo "update-manager is not running."
fi
